﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BoneImp {
	public class AtlasAttachmentLoader : AttachmentLoader{
		public Atlas atlas;

		public AtlasAttachmentLoader(Atlas atlas) {
			this.atlas = atlas;
		}

		public override Attachment newAttachment(AttachmentType type, string name) {
			switch (type) {
				case AttachmentType.ATTACHMENT_REGION: {
					AtlasRegion region = this.atlas.findRegion(name);
					if (region == null) {
						this.setError("Region not found: ", name);
						return null;
					}
					return new RegionAttachment(name, region);
				}
				default: {
					setError("Unknown attachment type: ", type.ToString());
					return null;
				}
			}
		}

		public override Region findRegion(string RegionName) {
			return atlas.findRegion(RegionName);
		}
	}
}
